<include file="public@header"/>
<style type="text/css">
    .pic-list li {
        margin-bottom: 5px;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('AdminFlower/flowerindex')}">花卉列表页</a></li>
        <li class="active"><a href="#">花卉添加</a></li>
    </ul>
    <form action="{:url('AdminFlower/addflower')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
        <div class="row">
            <div class="col-md-9">
                <table class="table table-bordered">
                    <tr>
                        <th style="text-align: center">花卉类型(必选)</th>
                        <td>
                            <div class="col-md-6 col-sm-10">
                                <select class="form-control" name="typeid" id="input-menus" >
                                    <foreach name="flowertypes" item = 'vo'>
                                        <option value="{$vo.id}">{$vo.name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align:center">花卉的名称(必填)</th>
                        <td>
                            <input type="text" value="" class="form-control" name="name" placeholder="请填写花卉的名称" >
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">标题(必填)</th>
                        <td>
                            <input type="text" value="" class="form-control" name="title"  placeholder="请填写花卉的标题" >
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">花卉封面图片(必填187*240)</th>
                        <td>
                            <div>
                                <input type="hidden" name="coverimg" class="form-control"
                                       id="js-thumbnail-input" required>
                                <div>
                                    <a href="javascript:uploadOneImage('图片上传','#js-thumbnail-input');">
                                        <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                             id="js-thumbnail-input-preview"
                                             width="135" style="cursor: pointer"/>
                                    </a>
                                    <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片"><font style="color: red">请把图片大小控制在1M以内！</font>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">鲜花图片（最多上传四张）(必填375*375)</th>
                        <td>
                            <ul id="photos" class="pic-list list-unstyled form-inline"></ul>
                            <a href="javascript:uploadImages();"
                               class="btn btn-default btn-sm">选择图片</a>
                        </td>
                    </tr>
                    <tr >
                        <th style="text-align: center">花卉的详情（必填）</th>
                        <td> <script type="text/plain" id="content" name="details" style="height:300px;" ></script>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">花卉注解</th>
                        <td> <textarea class="form-control" name="zhujie" style="height: 40px;"
                                       placeholder="格式：请填写花卉注解">
                            </textarea>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">花卉描述</th>
                        <td> <textarea class="form-control" name="description" style="height: 40px;"
                                       placeholder="格式：请填写花卉描述">
                            </textarea>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">套餐内容</th>
                        <td>
                            <textarea class="form-control" name="taocancontent" style="height: 40px;"
                                      placeholder="格式：请填写套餐内容">
                            </textarea>
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">产品信息</th>
                        <td>
                            <input type="text" value="" class="form-control" name="goodinfo" placeholder="格式：'数字=内容'，例如（1=一个月（4束)/3=三个月（12束））多个选项的话请用“/”分割开" >
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">鲜花现价（xx元/束）(必填)</th>
                        <td>
                            <input type="text" value="" class="form-control" name="price" placeholder="请填写花卉现有单价" >
                        </td>
                    </tr>
                    <tr>
                        <th style="text-align: center">鲜花原有价格（xx元/束）</th>
                        <td>
                            <input type="text" value="" class="form-control" name="price_first" placeholder="请填写花卉原有价格单价">
                        </td>
                    </tr>
                </table>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                        <a class="btn btn-default" href="{:url('AdminFlower/type')}">{:lang('BACK')}</a>
                    </div>
                </div>
            </div>

        </div>
    </form>
</div>
<script type="text/javascript" src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.WEB_ROOT;
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {
        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        editorcontent2 = new baidu.editor.ui.Editor();
        editorcontent2.render('content2');
        try {
            editorcontent.sync();
            editorcontent2.sync();
        } catch (err) {
        }

        //$('#more-template-select').val('page');
    });
</script>
<script>
    //=================上传图片===========================
    function uploadImages(){
        var len = $('#photos li').length;
        if(len>=4){
            alert('最多只能上传4张图片！');
        }else{
            uploadMultiImage('图片上传','#photos','photos-item-tpl');
        }
    }

    $(function(){
        $('.btn-cancel-thumbnail').click(function () {
            $('#js-thumbnail-input-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#js-thumbnail-input').val('');
        });

        $('.btn-cancel-thumbnail2').click(function () {
            $('#js-thumbnail-input-preview2').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#js-thumbnail-input2').html('');
        });
    });

</script>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="imgs[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
</body>
</html>